package com.wei.duowan.bbs.ui.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.google.gson.Gson;
import com.wei.duowan.bbs.R;
import com.wei.duowan.bbs.model.BbsBean;
import com.wei.duowan.bbs.presenter.BasePresenter;
import com.wei.duowan.bbs.ui.adapter.ForumsIndexAdapter;
import com.wei.duowan.bbs.utils.StringUtils;

import butterknife.Bind;

/**
 * 作者：赵若位
 * 时间：2019/10/21 22:03
 * 联系方式：1070138445
 * 功能：
 */
public class ForumsIndexFragment extends BaseLazyFragment
{
    @Bind(R.id.recyclerView)
    RecyclerView mRecyclerView;

    private ForumsIndexAdapter mAdapter;


    public static ForumsIndexFragment getFragment(@Nullable String paramerString)
    {
        ForumsIndexFragment fragment = new ForumsIndexFragment();
        Bundle bundle = new Bundle();
        bundle.putString(TAG, paramerString);
        fragment.setArguments(bundle);
        return fragment;
    }


    @Override
    protected BasePresenter createPresenter()
    {
        return null;
    }

    @Override
    protected int getLayoutID()
    {
        return R.layout.fragment_forums_index;
    }

    @Override
    protected void initView()
    {
        mRecyclerView.setLayoutManager(new LinearLayoutManager(mActivity));
        mAdapter = new ForumsIndexAdapter(mActivity);
        mRecyclerView.setAdapter(mAdapter);
    }

    @Override
    public void initData()
    {
        super.initData();
        String json = StringUtils.getAssetsJson("地下城与勇士.json");
        BbsBean data = new Gson().fromJson(json, BbsBean.class);
        mAdapter.setNewData(data.getVariables().getForum_threadlist());
    }
}
